home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2008 November / PCWNOV08.iso / Software / Freeware / Adobe Media Player 1.1 / adobe_media_player.air / AMP.swf / scripts / mx / controls / Alert.as next >
Encoding:
Text File  |  2008-07-17  |  8.4 KB  |  269 lines

  1. package mx.controls
  2. {
  3.    import flash.display.Sprite;
  4.    import flash.events.Event;
  5.    import mx.containers.Panel;
  6.    import mx.controls.alertClasses.AlertForm;
  7.    import mx.core.Application;
  8.    import mx.core.EdgeMetrics;
  9.    import mx.core.FlexVersion;
  10.    import mx.core.UIComponent;
  11.    import mx.core.mx_internal;
  12.    import mx.events.CloseEvent;
  13.    import mx.managers.PopUpManager;
  14.    import mx.resources.IResourceManager;
  15.    import mx.resources.ResourceManager;
  16.    
  17.    use namespace mx_internal;
  18.    
  19.    public class Alert extends Panel
  20.    {
  21.       mx_internal static var createAccessibilityImplementation:Function;
  22.       
  23.       private static var cancelLabelOverride:String;
  24.       
  25.       private static var _resourceManager:IResourceManager;
  26.       
  27.       private static var noLabelOverride:String;
  28.       
  29.       private static var _yesLabel:String;
  30.       
  31.       private static var yesLabelOverride:String;
  32.       
  33.       private static var _okLabel:String;
  34.       
  35.       private static var _cancelLabel:String;
  36.       
  37.       private static var okLabelOverride:String;
  38.       
  39.       private static var _noLabel:String;
  40.       
  41.       mx_internal static const VERSION:String = "3.0.0.0";
  42.       
  43.       public static const YES:uint = 1;
  44.       
  45.       public static const NO:uint = 2;
  46.       
  47.       public static const OK:uint = 4;
  48.       
  49.       public static const CANCEL:uint = 8;
  50.       
  51.       public static const NONMODAL:uint = 32768;
  52.       
  53.       private static var initialized:Boolean = false;
  54.       
  55.       public static var buttonHeight:Number = 22;
  56.       
  57.       public static var buttonWidth:Number = FlexVersion.compatibilityVersion < FlexVersion.VERSION_3_0 ? 60 : 65;
  58.       
  59.       mx_internal var alertForm:AlertForm;
  60.       
  61.       public var defaultButtonFlag:uint = 4;
  62.       
  63.       public var text:String = "";
  64.       
  65.       private var init:Boolean = false;
  66.       
  67.       public var buttonFlags:uint = 4;
  68.       
  69.       public var iconClass:Class;
  70.       
  71.       public function Alert()
  72.       {
  73.          super();
  74.          title = "";
  75.       }
  76.       
  77.       private static function initialize() : void
  78.       {
  79.          if(!initialized)
  80.          {
  81.             resourceManager.addEventListener(Event.CHANGE,static_resourceManager_changeHandler,false,0,true);
  82.             static_resourcesChanged();
  83.             initialized = true;
  84.          }
  85.       }
  86.       
  87.       private static function static_resourcesChanged() : void
  88.       {
  89.          cancelLabel = cancelLabelOverride;
  90.          noLabel = noLabelOverride;
  91.          okLabel = okLabelOverride;
  92.          yesLabel = yesLabelOverride;
  93.       }
  94.       
  95.       public static function get cancelLabel() : String
  96.       {
  97.          initialize();
  98.          return _cancelLabel;
  99.       }
  100.       
  101.       public static function set yesLabel(param1:String) : void
  102.       {
  103.          yesLabelOverride = param1;
  104.          _yesLabel = param1 != null ? param1 : resourceManager.getString("controls","yesLabel");
  105.       }
  106.       
  107.       public static function get noLabel() : String
  108.       {
  109.          initialize();
  110.          return _noLabel;
  111.       }
  112.       
  113.       public static function set cancelLabel(param1:String) : void
  114.       {
  115.          cancelLabelOverride = param1;
  116.          _cancelLabel = param1 != null ? param1 : resourceManager.getString("controls","cancelLabel");
  117.       }
  118.       
  119.       private static function get resourceManager() : IResourceManager
  120.       {
  121.          if(!_resourceManager)
  122.          {
  123.             _resourceManager = ResourceManager.getInstance();
  124.          }
  125.          return _resourceManager;
  126.       }
  127.       
  128.       public static function get yesLabel() : String
  129.       {
  130.          initialize();
  131.          return _yesLabel;
  132.       }
  133.       
  134.       public static function set noLabel(param1:String) : void
  135.       {
  136.          noLabelOverride = param1;
  137.          _noLabel = param1 != null ? param1 : resourceManager.getString("controls","noLabel");
  138.       }
  139.       
  140.       private static function static_resourceManager_changeHandler(param1:Event) : void
  141.       {
  142.          static_resourcesChanged();
  143.       }
  144.       
  145.       public static function set okLabel(param1:String) : void
  146.       {
  147.          okLabelOverride = param1;
  148.          _okLabel = param1 != null ? param1 : resourceManager.getString("controls","okLabel");
  149.       }
  150.       
  151.       public static function get okLabel() : String
  152.       {
  153.          initialize();
  154.          return _okLabel;
  155.       }
  156.       
  157.       public static function show(param1:String = "", param2:String = "", param3:uint = 4, param4:Sprite = null, param5:Function = null, param6:Class = null, param7:uint = 4) : Alert
  158.       {
  159.          var _loc8_:Boolean = !!(param3 & Alert.NONMODAL) ? false : true;
  160.          if(!param4)
  161.          {
  162.             param4 = Sprite(Application.application);
  163.          }
  164.          var _loc9_:Alert = new Alert();
  165.          if(Boolean(param3 & Alert.OK) || Boolean(param3 & Alert.CANCEL) || Boolean(param3 & Alert.YES) || Boolean(param3 & Alert.NO))
  166.          {
  167.             _loc9_.buttonFlags = param3;
  168.          }
  169.          if(param7 == Alert.OK || param7 == Alert.CANCEL || param7 == Alert.YES || param7 == Alert.NO)
  170.          {
  171.             _loc9_.defaultButtonFlag = param7;
  172.          }
  173.          _loc9_.text = param1;
  174.          _loc9_.title = param2;
  175.          _loc9_.iconClass = param6;
  176.          if(param5 != null)
  177.          {
  178.             _loc9_.addEventListener(CloseEvent.CLOSE,param5);
  179.          }
  180.          if(param4 is UIComponent)
  181.          {
  182.             _loc9_.moduleFactory = UIComponent(param4).moduleFactory;
  183.          }
  184.          PopUpManager.addPopUp(_loc9_,param4,_loc8_);
  185.          _loc9_.setActualSize(_loc9_.getExplicitOrMeasuredWidth(),_loc9_.getExplicitOrMeasuredHeight());
  186.          return _loc9_;
  187.       }
  188.       
  189.       override public function styleChanged(param1:String) : void
  190.       {
  191.          var _loc2_:String = null;
  192.          super.styleChanged(param1);
  193.          if(param1 == "messageStyleName")
  194.          {
  195.             _loc2_ = getStyle("messageStyleName");
  196.             styleName = _loc2_;
  197.          }
  198.          if(mx_internal::alertForm)
  199.          {
  200.             mx_internal::alertForm.styleChanged(param1);
  201.          }
  202.       }
  203.       
  204.       override protected function measure() : void
  205.       {
  206.          var _loc1_:EdgeMetrics = null;
  207.          super.measure();
  208.          _loc1_ = viewMetrics;
  209.          measuredWidth = Math.max(measuredWidth,mx_internal::alertForm.getExplicitOrMeasuredWidth() + _loc1_.left + _loc1_.right);
  210.          measuredHeight = mx_internal::alertForm.getExplicitOrMeasuredHeight() + _loc1_.top + _loc1_.bottom;
  211.       }
  212.       
  213.       override protected function resourcesChanged() : void
  214.       {
  215.          super.resourcesChanged();
  216.          static_resourcesChanged();
  217.       }
  218.       
  219.       override protected function initializeAccessibility() : void
  220.       {
  221.          if(Alert.mx_internal::createAccessibilityImplementation != null)
  222.          {
  223.             Alert.mx_internal::createAccessibilityImplementation(this);
  224.          }
  225.       }
  226.       
  227.       override protected function updateDisplayList(param1:Number, param2:Number) : void
  228.       {
  229.          var _loc4_:Number = NaN;
  230.          var _loc5_:Number = NaN;
  231.          super.updateDisplayList(param1,param2);
  232.          var _loc3_:EdgeMetrics = viewMetrics;
  233.          mx_internal::alertForm.setActualSize(param1 - _loc3_.left - _loc3_.right - getStyle("paddingLeft") - getStyle("paddingRight"),param2 - _loc3_.top - _loc3_.bottom - getStyle("paddingTop") - getStyle("paddingBottom"));
  234.          if(!init)
  235.          {
  236.             if(parent == systemManager)
  237.             {
  238.                _loc4_ = (screen.width - measuredWidth) / 2;
  239.                _loc5_ = (screen.height - measuredHeight) / 2;
  240.             }
  241.             else
  242.             {
  243.                _loc4_ = (parent.width - measuredWidth) / 2;
  244.                _loc5_ = (parent.height - measuredHeight) / 2;
  245.             }
  246.             move(Math.round(_loc4_),Math.round(_loc5_));
  247.             init = true;
  248.          }
  249.       }
  250.       
  251.       override protected function createChildren() : void
  252.       {
  253.          super.createChildren();
  254.          var _loc1_:String = getStyle("messageStyleName");
  255.          if(_loc1_)
  256.          {
  257.             styleName = _loc1_;
  258.          }
  259.          if(!mx_internal::alertForm)
  260.          {
  261.             mx_internal::alertForm = new AlertForm();
  262.             mx_internal::alertForm.styleName = this;
  263.             addChild(mx_internal::alertForm);
  264.          }
  265.       }
  266.    }
  267. }
  268.  
  269.